﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCRUM.Core.DataProviders;
using SCRUM.Core.BusinessObjects;

namespace SCRUM.Core.DAO
{
    /// <summary>
    /// Static access object for handling UserStories
    /// </summary>
    public static class DAOUserStory
    {
        /// <summary>
        /// Creates the specified UserStory.
        /// </summary>
        /// <param name="userStory">The specific UserStory.</param>
        /// <param name="projectId">UserStory is in project</param>
        public static UserStory CreateNewUserStory(UserStory userStory, int projectId)
        {
            return ProviderFactory.Provider.CreateUserStory(userStory, projectId);
        }

        /// <summary>
        /// Updates the specified UserStory.
        /// </summary>
        /// <param name="userStory">The specific UserStory.</param>
        /// <param name="projectId">UserStory is in project</param>
        public static void UpdateUserStory(UserStory userStory, int projectId)
        {
            ProviderFactory.Provider.UpdateUserStory(userStory, projectId);
        }

        /// <summary>
        /// Updates the specified UserStory.
        /// </summary>
        /// <param name="userStory">The specific UserStory.</param>
        public static void UpdateUserStory(UserStory userStory)
        {
            ProviderFactory.Provider.UpdateUserStory(userStory);
        }


        /// <summary>
        /// Deletes the specified userStory.
        /// </summary>
        /// <param name="userStory">The specific UserStory.</param>
        public static void DeleteUserStory(UserStory userStory)
        {
            ProviderFactory.Provider.DeleteUserStory(userStory.ID);
        }

        /// <summary>
        /// Deletes the UserStory.
        /// </summary>
        /// <param name="userStoryID">The UserStory ID.</param>
        public static void DeleteUserStory(int userStoryID)
        {
            ProviderFactory.Provider.DeleteUserStory(userStoryID);
        }
        
        /// <summary>
        /// Returns user story according to its id
        /// </summary>
        /// <returns>user story</returns>
        public static UserStory GetUserStoryByID(int userStoryID)
        {
            return ProviderFactory.Provider.GetUserStoryByID(userStoryID);
        }

        /// <summary>
        /// Gets the user story by BLI ID.
        /// </summary>
        /// <param name="bliID">ID of the BLI.</param>
        /// <returns>user story containing that BLI</returns>
        public static UserStory GetUserStoryByBliID(int bliID)
        {
            return ProviderFactory.Provider.GetUserStoryByBliID(bliID);
        }

        /// <summary>
        /// Gets all user stories for specific sprint.
        /// </summary>
        /// <param name="sprintID">All sprints in sprint with this id</param>
        /// <returns>List with all user stories of the sprint.</returns>
        public static IList<UserStory> GetAllUserStoriesForSprint(int sprintID)
        {
            return ProviderFactory.Provider.GetAllUserStoriesForSprint(sprintID);
        }

        /// <summary>
        /// Gets all user stories for specific release.
        /// </summary>
        /// <param name="releaseID">All sprints in release with this id</param>
        /// <returns>List with all user stories of the release.</returns>
        public static IList<UserStory> GetAllUserStoriesForRelease(int releaseID)
        {
            return ProviderFactory.Provider.GetAllUserStoriesForRelease(releaseID);
        }

        /// <summary>
        /// Gets all user stories for specific project.
        /// </summary>
        /// <param name="projectID">All sprints in project with this id</param>
        /// <returns>List with all user stories of the project.</returns>
        public static IList<UserStory> GetAllUserStoriesForProject(int projectID)
        {
            return ProviderFactory.Provider.GetAllUserStoriesForProject(projectID);
        }

        /// <summary>
        /// Method without parameter gets all UserStories
        /// </summary>
        /// <returns>all UserStories</returns>
        public static IList<UserStory> GetAllUserStories()
        {
            return ProviderFactory.Provider.GetAllUserStories();
        }

        /// <summary>
        /// Method without parameter gets all UserStories
        /// </summary>
        /// <returns>all UserStories</returns>
        public static IList<UserStory> GetAllUserStories(int projectID, int releaseID, int sprintID, int userStoryID, int bliID, string name, int stateID, int priority)
        {
            return ProviderFactory.Provider.GetAllUserStories(projectID, releaseID, sprintID, userStoryID, bliID, name, stateID, priority);
        }

		/// <summary>
		/// Updates the sprint of the user story.
		/// </summary>
		/// <param name="userStoryID">The user story ID.</param>
		/// <param name="sprintID">The sprint ID.</param>
		public static void UpdateUserStorySprint(int userStoryID, int? sprintID)
		{
			ProviderFactory.Provider.UpdateUserStorySprint(userStoryID, sprintID);
		}

		/// <summary>
		/// Gets the unassigned stories.
		/// </summary>
		/// <returns>List of unassigned userstories.</returns>
		public static IList<UserStory> GetUnassignedStories(int projectID)
		{
            return ProviderFactory.Provider.GetUnassignedStories(projectID);
		}
	}
}
